package com.itcs.trading.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.itcs.trading.model.UserAccountInfo;

public interface UserAccountInfoMapper {
    int deleteByPrimaryKey(Long userId);

    int insert(UserAccountInfo record);

    int insertSelective(UserAccountInfo record);
    
    UserAccountInfo selectByPrimaryKey(Long userId);
    /**
     * 根据用户ID 获取相关金额
     * zhaojins 20171224
     * */
    @Select("select * from user_account_info where user_id = #{userId,jdbcType=BIGINT}")
    Map<String,Object> qryList(Long userId);
    int updateByPrimaryKeySelective(UserAccountInfo record);

    int updateByPrimaryKey(UserAccountInfo record);
    /**
     * 支付完成后，更新金额
     * zhaojins 20171224
     * */
    @Update("update user_account_info set account_balance = #{accountBalance,jdbcType=DECIMAL} where user_id = #{userId,jdbcType=BIGINT}")
    int updateAmount(Map<String,Object> paramMap);
	/** 
	* @Title: wallet 
	* @Description: 用户资金
	* @param id
	* @return List<Map<String,Object>>
	* @throws 
	*/
    @Select("select "
    		+ "b.user_id user_id,"
    		+ "b.agent_name agent_name,"
    		+ "b.agent_id_num agent_id_num,"
    		+ "b.mobile mobile,"
    		+ "a.account_type account_type,a.account_balance account_balance,"
    		+ "a.credit_money credit_money,"
    		+ "a.account_registe_date account_registe_date,"
    		+ "a.service_fee service_fee,"
    		+ "a.account_state account_state,"
    		+ "a.account_modify_date account_modify_date "
    		+ "from user_account_info a,user_customer_info b "
    		+ "where a.user_id=b.user_id and b.user_id=#{userId}")
	List<Map<String, Object>> wallet(@Param("userId")Long id);
    
	//扣款
	void payBalance(UserAccountInfo etcsUser);
}